<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simpla Admin</title>
<jsp:include page="css.jsp"></jsp:include>
<jsp:include page="script.jsp"></jsp:include>
<script type="text/javascript">
	var path = '<%=request.getContextPath()%>';
	function goPage(page) {
		document.getElementById("currentPage").value = page;
		document.getElementById("n_form").submit();
	}
	
	function deleteSelectedSmsShieldWord(){
		var checkbox = document.getElementsByName("checkbox");
		var checkedItem = "";
		for ( var i = 0; i < checkbox.length; i++) {
			if(checkbox[i].checked){
				checkedItem+=checkbox[i].value+",";
			}
		}
		if(checkedItem.length<1){
			showAlertDialog("선택하세요!",null);
			return;
		}
		checkedItem = checkedItem.substring(0,checkedItem.length-1);
		$("<div>삭제하시겠습니까?</div>").dialog({
			title:'확인?',
			modal:true,
			resizable:false,
			draggable:false,
			close : function (event) {
				$(this).dialog("destroy");
			}, 
			buttons : {
				'확인':function (event) {
					$(this).dialog("destroy");
					$.ajax({
						type : "GET",
						url : path + "/deleteSmsShieldWord.htm",
						data : {
							sids : checkedItem
						},
						dataType : "text",
						success : function(result) {
							if (result == "success") {
								reload();
							} else {
								showAlertDialog("삭제에 실패하였습니다!",null);
							}
						},
						error : function() {
							showAlertDialog("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오",null);
						}
					});
				},
				'취소':function (event) {
					$(this).dialog("destroy");
				}
			}
		});
	}
	

	function reload() {
		document.getElementById("n_form").submit();
	}
</script>
</head>
<body>
	<div id="body-wrapper">
		<!-- Wrapper for the radial gradient background -->
		<div id="sidebar">
			<div id="sidebar-wrapper">
				<!-- Sidebar with logo and menu -->
				<h1 id="sidebar-title">
					<a href="#">Simpla Admin</a>
				</h1>
				<!-- Logo (221px wide) -->
				<a href="#"><img id="logo" src="<%=request.getContextPath()%>/images/logo.png" alt="Simpla Admin logo" /></a>
				<!-- Sidebar Profile links -->
				<jsp:include page="info.jsp" />
				<ul id="main-nav">
					<!-- Accordion Menu -->
					<li><a href="javascript:void();" class="nav-top-item"> <!-- Add the class "current" to current menu item --> 사용자관리
					</a>
						<ul>
							<li><a href="<%=request.getContextPath()%>/userList.htm" >사용자</a></li>
						</ul></li>
					<li><a href="javascript:void();" class="nav-top-item  current">개인정보관리</a>
						<ul>
							<li><a href="<%=request.getContextPath()%>/smsShieldWordList.htm" class="current">문구차단</a></li>
							<li><a href="<%=request.getContextPath()%>/changePwd.htm">비밀번호수정</a></li>
							<li><a href="<%=request.getContextPath()%>/setting.htm" >설정</a></li>
							<li><a href="javascript:logout('<%=request.getContextPath()%>');">로그오프</a></li>
						</ul></li>
				</ul>
			</div>
		</div>
		<!-- End #sidebar -->
		<div id="main-content">
			<!-- Main Content Section with everything -->
			<jsp:include page="noscript.jsp"></jsp:include>
			<div class="clear"></div>
			<!-- End .clear -->
			<div class="content-box">
				<!-- Start Content Box -->
				<div class="content-box-header">
					<h3>문구차단</h3>
					<div style="float: right;text-align: center;">
						<img onclick="showAddSmsShieldWordDialog();" src="<%=request.getContextPath()%>/images/icons/add.png" class="menu-icon" />
						<img onclick="deleteSelectedSmsShieldWord();" src="<%=request.getContextPath()%>/images/icons/delete.png" class="menu-icon" style="margin-right: 20px;"/>
					</div>
					<div class="clear"></div>
				</div>
				<!-- End .content-box-header -->
				<div class="content-box-content">
					<div class="tab-content default-tab" id="tab1">
						<table>
							<thead>
								<tr>
									<th><input class="check-all" type="checkbox" /></th>
									<th>순서</th>
									<th>문구 </th>
								</tr>
							</thead>
							<tfoot>
								<tr>
									<td colspan="6">
										<form action="<%=request.getContextPath()%>/smsShieldWordList.htm" method="post" id="n_form">
											<div class="pagination">
												<s:if test="words.currentPage<2">
													<a href="javascript:void();" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:void();" title="이전">&laquo; 이전</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(1);" title="처음페지">&laquo; 처음페지</a>
													<a href="javascript:goPage(${words.currentPage}-1);" title="이전">&laquo; 이전</a>
												</s:else>
												[<b>${words.currentPage}</b>페지|총<b>${words.pageCount}</b>페지]
												<s:if test="words.currentPage>=words.pageCount">
													<a href="javascript:void();" title="다음">다음 &raquo;</a>
													<a href="javascript:void();" title="마지막페지">마지막페지&raquo;</a>
												</s:if>
												<s:else>
													<a href="javascript:goPage(${words.currentPage+1});" title="다음">다음 &raquo;</a>
													<a href="javascript:goPage(${words.pageCount})" title="마지막페지">마지막페지 &raquo;</a>
												</s:else>
											</div>
											<!-- End .pagination -->
											<div class="clear"></div>
											<input type="hidden" value="${words.currentPage}" name="cPage"
												id="currentPage" />
										</form>
									</td>
								</tr>
							</tfoot>
							<tbody>
								<s:iterator value="words.datas" id="item" status="index">
									<tr>
										<td><input type="checkbox" name="checkbox" value="<s:property value="#item.id"/>"/></td>
										<td><s:property value="#index.index+1" /></td>
										<td><s:property value="#item.word"/></td>
									</tr>
								</s:iterator>
							</tbody>
						</table>
					</div>
					<!-- End #tab1 -->
				</div>
				<!-- End .content-box-content -->
			</div>
			<div class="clear"></div>
			<jsp:include page="footer.jsp"></jsp:include>
			<!-- End #footer -->
		</div>
		<!-- End #main-content -->
	</div>
	
	<div id="add_smsshieldword" style="display: none;">
		<form action="">
			문구：
			<textarea class="textarea" cols="2" rows="7" id="content"></textarea>
		</form>
	</div>
	<script type="text/javascript">
	var add_smsshieldword_dialog = $("#add_smsshieldword").dialog( {
		bgiframe :false,
		resizable :false,
		autoOpen :false,
		modal :true,
		draggable:false,
		title:"문구추가",
		overlay : {
			backgroundColor :'#000',
			opacity :0.5
		},
		height : 250,
		width : 400,
		buttons : {
			"확인":function(){
				var intputkeyword = $("#content").val();
				var _kerword = intputkeyword.split("\n").join(",");
				var path='<%=request.getContextPath()%>';
				var _requestUrl = path +"/addSmsShieldWord.htm";
				$.ajax({
					type: "POST",
		            url: _requestUrl,
		            data:{
		            	keywords:_kerword
		            },
		            dataType: "text",
		            success: function(result){
		            	 if(result=="success"){
		            		 goPage(1);
		                 }else{
		              	   alert("삭제에 실패하였습니다!");
		                 }
		            },
		            error: function(){
		              alert("네트워크원인으로 인하여 지연되고있습니다.잠시후 다시 시도해주십시오");
		            }
				});
			},
			"취소":function(){
				add_smsshieldword_dialog.dialog('close');
			}
		}
	});

	function showAddSmsShieldWordDialog(){
		add_smsshieldword_dialog.dialog('open');
	}
	</script>
</body>
<!-- Download From www.exet.tk-->
</html>
